/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 battlefield_metrics.h

	$Header: /heroes4/battlefield_metrics.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( BATTLEFIELD_METRICS_H_INCLUDED )
#define BATTLEFIELD_METRICS_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "adventure_tile_size.h"
#include "map_point.h"
#include "rational.h"
#include "screen_point.h"

int const k_battlefield_base_height = 30;

int const k_battlefield_logical_view_width = 1180;
int const k_battlefield_logical_view_height = 1024;
t_screen_point const	k_battlefield_logical_view_size(
							k_battlefield_logical_view_width,
							k_battlefield_logical_view_height );

int const k_battlefield_terrain_tile_width = k_adventure_tile_width;
int const k_battlefield_terrain_tile_height = k_adventure_tile_height;

int const k_battlefield_terrain_iso_cell_height = k_battlefield_terrain_tile_height/2;

t_screen_point const	k_battlefield_terrain_tile_size(
							k_battlefield_terrain_tile_width,
							k_battlefield_terrain_tile_height );

int const k_battlefield_cells_per_terrain_tile = 2;
int const k_battlefield_cell_shift = 1;
int const k_battlefield_cell_mask = ( 1 << k_battlefield_cell_shift ) - 1;

int const k_battlefield_cell_width = k_battlefield_terrain_tile_width / k_battlefield_cells_per_terrain_tile;
int const k_battlefield_cell_height = k_battlefield_terrain_tile_height / k_battlefield_cells_per_terrain_tile;
t_screen_point const	k_battlefield_cell_size(
							k_battlefield_cell_width,
							k_battlefield_cell_height );

int const k_battlefield_subcells_per_cell = 16;
int const k_battlefield_subcell_shift = 4;
int const k_battlefield_subcell_mask = ( 1 << k_battlefield_subcell_shift ) - 1;;

t_map_point_2d const k_battlefield_half_cell( k_battlefield_subcells_per_cell / 2,
											 k_battlefield_subcells_per_cell / 2 );

int const k_battlefield_subcell_width = k_battlefield_cell_width / k_battlefield_subcells_per_cell;
int const k_battlefield_subcell_height = k_battlefield_cell_height / k_battlefield_subcells_per_cell;
t_screen_point const	k_battlefield_subcell_size(
							k_battlefield_subcell_width,
							k_battlefield_subcell_height );

inline t_map_point_2d get_cell_center( t_map_point_2d const& cell )
{
	return (cell << k_battlefield_subcell_shift) + k_battlefield_half_cell;
}

inline t_map_point_2d get_cell( t_map_point_2d const& subcell )
{
	return (subcell >> k_battlefield_subcell_shift);
}

enum t_battlefield_view_size_id
{
	k_view_size_small,
	k_view_size_medium,
	k_view_size_large,

	k_view_size_count,
};

typedef t_rational<int>				 t_rational_int;
typedef t_point_2d< t_rational_int > t_rational_point;

struct t_battlefield_view_size
{
public:
	// Data members
	t_screen_point		size;
	t_rational_point	view_ratio;

	// Constructor
	t_battlefield_view_size( t_screen_point const & size_arg );
};

t_battlefield_view_size_id compute_view_size_id( t_screen_point const & view_size );

t_battlefield_view_size const& 
get_battlefield_view_size( t_battlefield_view_size_id view_size );



#endif // !defined( BATTLEFIELD_METRICS_H_INCLUDED )
